package com.juc.threadPoolExecutor.threadPoolExecutor9;

import java.lang.Thread.UncaughtExceptionHandler;
import java.util.Date;
import java.util.concurrent.ThreadFactory;
/**
 * ThreadFactory
 * 自定义处理异常
 *
 */
public class MyThreadFactoryB implements ThreadFactory{

	@Override
	public Thread newThread(Runnable r) {
		Thread newThread = new Thread(r);
		newThread.setName(" 我的新名字 ： " + new Date());
		newThread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
			@Override
			public void uncaughtException(Thread t, Throwable e) {
                 System.out.println(" 自定义处理异常启用:   " + t.getName() + "   " + e.getMessage());	
                 e.printStackTrace();
			}
		});
		return newThread;
	}


}
